package com.egoo.ticket.server.controller;

import com.egoo.ticket.server.service.InterfaceConfigurationService;
import com.egoo.ticket.server.utils.common.DbResponse;
import com.egoo.ticket.server.utils.common.ResponseConstant;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author：victor_tang
 * @Date ：2020/1/6
 * @Description：接口配置控制层
 */
@Slf4j
@RestController
@RequestMapping(value = "/v1/InterfaceConfiguration", produces = "application" +
		"/json")
@Api(value = "接口配置管理",tags = "接口配置管理",description = "接口配置管理")
public class InterfaceConfigurationController {

	@Autowired
	private InterfaceConfigurationService interfaceConfigurationService;

	@ApiOperation(value = "根据接口类型编码获取接口信息", notes = "根据接口类型编码获取接口信息")
	@RequestMapping(method = RequestMethod.GET, value ="/getInterfaceInfoByTypeCode")
	public DbResponse getInterfaceInfoByTypeCode(@ApiParam(value = "typeCode", required = true)
									@RequestParam(name = "typeCode") String typeCode) {
		if (StringUtils.isEmpty(typeCode)) {
			return new DbResponse(ResponseConstant.RES_FAIL_CODE,
					"接口类型编码不能为空！");
		}
		try {
			// 查询字典详情列表
			return interfaceConfigurationService.getInterfaceInfoByTypeCode(typeCode);

		} catch (Exception e) {
			log.error("根据接口类型编码获取接口信息查询异常：" + e);
			return new DbResponse(ResponseConstant.RES_FAIL_CODE, "根据接口类型编码获取接口信息查询异常：" + e);
		}
	}
}
